<?php
namespace Administrador\Model\Entity;

use Zend\Session\Container;
use Zend\Db\Adapter\Adapter;
use Zend\Cache\Storage\Adapter\Session;
use Zend\Db\TableGateway\TableGateway;

class Usuarios extends TableGateway
{
  private $session;
  public function __construct(Adapter $adapter = null, $databaseSchema = null, ResultSet $selectResultPrototype = null)
  {
    return parent::__construct('user', $adapter, $databaseSchema,$selectResultPrototype);
  }
  
  public function getUsuario($datosPost)
  {
    $user = $datosPost["username"];
    $pass = md5($datosPost["password"]);
    $busqueda = array("user"=>$user,"pasword"=>$pass);
    $datos = $this->select($busqueda);
    
    $aux = $datos->toArray();
    
    if(!empty($aux[0]["id_user"]))
    {
      $this->session = new Container("univision");
      $this->session->id = $aux[0]["id_user"];
      $this->session->user = $aux[0]["user"];
    }  
    return array("total"=>count($datos));
  }
  
  public function getDatos()
  {
    $d = $this->select();
    return $d->toArray();
  }
  
  
}
?>
